﻿using NAnt.Core;
using NAnt.Core.Attributes;
using NHibernate.Tool.hbm2ddl;

namespace Sentient.Nant.Tasks
{
    [TaskName("db.schema")]
    public class CreateSchemaTask : NHibernateTask
    {
        protected override void ExecuteTask()
        {
            try
            {
                new SchemaExport(NHConfig).Execute(false, true, false, false);
            }
            catch
            {
                Log(Level.Error, "Error creating database schema: {0}\n{1}", Catalog, ConnectionString);
                throw;
            }
        }
    }
}
